/*!
 * \file Stage.cpp
 * \brief Implements a Stage class as stage in the execution plan after parsing
 *        the arguments
 *
 * This file contains the implementation for the CLAP :: Stage Class.
 * This is a class to generate a stage to execute given inputs and a set of
 * options and subcommands available.
 */

#include <CLAP/Stage.h>
#include <CLAP/Switch.h>

using namespace libCLAP;
using namespace libCLAP :: CLAP;


Stage :: Stage ( const Common :: String & name ) :
   _Name ( name ),
   _Parent ( NULL ),
   _Next ( NULL )
{
}

Stage :: Stage ( const Common :: String & name,
                 Stage & parent ) :
   _Name ( name ),
   _Parent ( &parent ),
   _Next ( NULL )
{
}

Stage :: ~Stage ( void ) throw ()
{
}

void Stage :: AddSwitch ( Switch & addition )
{
   _Switches [ addition.Name () ] = &addition;
}

void Stage :: AddArgument ( Common :: String & addition )
{
   _Arguments.push ( addition );
}

const Common :: String Stage :: Shift ( void )
{
   Common :: String argument = _Arguments.front ();
   _Arguments.pop ();
   return argument;
}

const map < Common :: String, Switch* > & Stage :: Switches ( void ) const
{
   return _Switches;
}

map < Common :: String, Switch* > & Stage :: Switches ( void )
{
   return _Switches;
}

const queue < Common :: String > & Stage :: Arguments ( void ) const
{
   return _Arguments;
}

const Common :: String & Stage :: Name ( void ) const
{
   return _Name;
}

const queue < Common :: String > & Stage :: Arguments
      ( const queue < Common :: String > & variable )
{
   _Arguments = variable;
   return _Arguments;
}

const map < Common :: String, Switch* > & Stage :: Switches
      ( const map < Common :: String, Switch* > & variable )
{
   _Switches = variable;
   return _Switches;
}

const Common :: String & Stage :: Name ( Common :: String & variable )
{
   _Name = variable;
   return _Name;
}

Stage & Stage :: Parent ( void ) const
{
   return *_Parent;
}

Stage & Stage :: Next ( void ) const
{
   return *_Next;
}

Stage & Stage :: Parent ( Stage & variable )
{
   _Parent = &variable;
   return *_Parent;
}

Stage & Stage :: Next ( Stage & variable )
{
   _Next = &variable;
   return *_Next;
}
